package com.dinzeer.legendreliclib.effect;

import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.effect.MobEffectCategory;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.ai.attributes.AttributeInstance;
import net.minecraft.world.entity.ai.attributes.AttributeMap;
import net.minecraft.world.entity.ai.attributes.AttributeModifier;
import net.minecraft.world.entity.ai.attributes.Attributes;

import java.util.UUID;

public  class SuperStrengthEffect extends MobEffect {
    private static final UUID ATTACK_DAMAGE_UUID = UUID.nameUUIDFromBytes("super_strength_attack_damage".getBytes());

    public SuperStrengthEffect(MobEffectCategory category, int color) {
        super(category, color);
    }

    // 新增效果结束时的清理逻辑
    @Override
    public void removeAttributeModifiers(LivingEntity entity, AttributeMap attributes, int amplifier) {
        super.removeAttributeModifiers(entity, attributes, amplifier);
        AttributeInstance attr = entity.getAttribute(Attributes.ATTACK_DAMAGE);

        attr.removeModifier(ATTACK_DAMAGE_UUID);

    }
    @Override
    public void applyEffectTick(LivingEntity entity, int amplifier) {
        AttributeInstance attr = entity.getAttribute(Attributes.ATTACK_DAMAGE);
        if (attr != null) {
            // 移除旧修饰符防止叠加
            attr.removeModifier(ATTACK_DAMAGE_UUID);




            attr.addTransientModifier(new AttributeModifier(
                    ATTACK_DAMAGE_UUID,
                    "Super Strength",
                    0.6D * (amplifier + 1),
                    AttributeModifier.Operation.MULTIPLY_BASE
            ));
        }
    }

    @Override
    public boolean isDurationEffectTick(int duration, int amplifier) {
        return true; // 持续生效
    }







}
